import request from '@/utils/request'
import scope from './scope'
const apiPrefix = `${process.env.VUE_APP_BASE_API}/${scope}/document/`

// 文档管理
export const getDocuments = (params, config = {}) => {
    return request.get(apiPrefix + 'list', { params: params, ...config })
}
export const getDocumentImages = (params, config = {}) => {
    return request.get(apiPrefix + params.id + '/image-list', { params: params, ...config })
}
export const getGroup = (params, config = {}) => {
    return request.get(apiPrefix + 'group/' + params.id, { params: params, ...config })
}
export const getMenu = (params, config = {}) => {
    return request.get(apiPrefix + 'menu/' + params.id, { params: params, ...config })
}
export const getContent = (params, config = {}) => {
    return request.get(apiPrefix + 'content/' + params.id, {...config })
}
export const addGroup = (params, config = {}) => {
    return request.post(apiPrefix + 'group', params, config)
}
export const addMenu = (params, config = {}) => {
    return request.post(apiPrefix + 'menu', params, config)
}
export const updateGroup = (params, config = {}) => {
    return request.put(apiPrefix + 'group', params, config)
}
export const updateMenu = (params, config = {}) => {
    return request.put(apiPrefix + 'menu', params, config)
}
export const updateContent = (params, config = {}) => {
    return request.put(apiPrefix + 'content', params, config)
}
export const removeDocument = (params, config = {}) => {
    return request.delete(apiPrefix + params.id, { params: params, ...config })
}
export const deleteImage = (params, config = {}) => {
    return request.delete(apiPrefix + 'image/' + params.documentId, { params: params, ...config })
}